package com.guigu.alibaba.controller;


import com.guigu.springcloud.common.CommonResult;
import com.guigu.springcloud.entity.Payment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
@RequestMapping("/nacosOpenfeign")
public class PaymentController {

    private static HashMap<Long, Payment> data = new HashMap<>();

    static {
        data.put(2010L, new Payment(2010L, "serial003"));
        data.put(2L, new Payment(2L, "serial004"));
        data.put(3L, new Payment(3L, "serial005"));
        data.put(4L, new Payment(4L, "serial006"));
    }

    @Value("${server.port}")
    private String serverPort;

    @GetMapping("/{id}")
    public CommonResult getById(@PathVariable("id") Long id) {
        return CommonResult.voData(200, "success " + serverPort, data.get(id));
    }
}
